Stability Demo

The code is written in Julia.

To show you how to develop you own "test problem" to look at stability of numerical methods.

An ODE solution that relaxes to a bounded function.

Let $h(t)$ be a bounded function. Consider the ODE

\begin{align*} \begin{cases} u'(t) = \lambda(u(t) - h(t)) + h'(t),\\ u(0) = \eta. \end{cases} \end{align*}

Forward Euler

Leapfrog (a 2-step method)

Trapezoid

At each time step we seek $U^{n+1}$ which solves

$$U^{n+1} - U^{n} = \frac{k}{2} \left( f(U^{n+1},t_{n+1}) + f(U^{n},t_n) \right).$$

So, we look for a zero of

$$ g(u,U^{n},t,t_n) = u - U^{n} - \frac{k}{2} \left( f(u,t) + f(U^{n},t_n) \right).$$

The Jacobian is given by

$$ D_u g(u) = I - \frac{k}{2} D_uf(u,t). $$